<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue.js学习</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>   <!--引入vue.js-->
</head>
<body>
    <div id="xue">
        <p>今年3月3日发卖的任天堂新一代主机Switch的价格是：{{price}}円，含税价格为：{{priceInTax}}円，折合人民币为：{{priceChinaRMB}}元。</p>
        <button @click="btnClick(10800)">把含税改价为10800円</button>
    </div>
    <script>
        var hehe = new Vue({
            el: '#xue',
            data: {
                price: 29980
            },
            computed: {
                priceInTax: {
                    get:function(){
                        return this.price * 1.08;
                    },
                    set: function(value){
                        this.price = value / 1.08;
                    }
                },
                priceChinaRMB: function(){
                    return Math.round(this.priceInTax / 16.75);
                },
            },
            methods: {
                btnClick: function(newPrice){
                    this.priceInTax = newPrice;
                },
            },
        });
    </script>
</body>
</html>